


package com.eben.model;

import android.graphics.Canvas;
import android.graphics.Paint;

public abstract class GameObject{
	protected double velocity; 
	protected double direction;
	protected Position position;
	protected Paint paint;
	protected int radius;
	protected int color;
	private boolean isOnGrid = true;
	
	/**
	 * Sets the instance variables.
	 * @param velocity the velocity of the GameObject
	 * @param direction the direction of the GameObject
	 * @param position the position of the GameObject
	 * @param radius the radius of the GameObject
	 * @param color the color of the GameObject
	 */
	public GameObject(double velocity, double direction, Position position, int radius, int color){
		this.velocity = velocity;
		this.direction = direction;
		this.position = new Position(position.getX(), position.getY());
		this.radius = radius;
		this.color = color;
		paint = new Paint();
		paint.setAntiAlias(true);
	}
	
	/**
	 * Specifies how the object should be drawn on the screen.
	 * @param canvas the canvas to draw on.
	 */
	public abstract void draw(Canvas canvas);
	
	/**
	 * Updates the position for the object. Note that objects have their on calculations for how to update
	 * the position and the only object that will care about what position you enter is Pointer.
	 * @param position the position of the cursor.
	 */
	public abstract void updatePosition();
	
	public Position getPosition (){
		return position;
	}
	
	/**
	 * Sets the position of the GameObject
	 * @param x the x coordinate.
	 * @param y the y coordinate
	 */
	public void setPosition(double x, double y){
		position.setX(x);
		position.setY(y);
	}
	
	/**
	 * Sets the direction of the GameObject.
	 * @param direction the direction in radians according to the unit circle.
	 */
	public void setDirection(double direction) {
		this.direction = direction;
	}
	
	/**
	 * Returns the radius of the GameObject.
	 * @return the radius of the GameObject.
	 */
	public int getRadius(){
		return radius;
	}
	
	/**
	 * Checks if the GameObject is on the board according to the system.
	 * @return True if the GameObject's position is on the grid. False if it's not AND it has never been before.
	 */
	public boolean isOnGrid(){
		return isOnGrid;
	}
	
	/**
	 * Sets the GameObject to be on the board.
	 * @param b true if it is on grid. False if not.
	 */
	public void setOnGrid(boolean b){
		isOnGrid = b;
	}

}